import { request } from 'umi';
import { RentCost } from '@/data-type'
import { BaseService } from './baseService';
class RentCostServiceImpl implements BaseService<RentCost> {
  async queryList(options?: { [key: string]: any; } | undefined): Promise<{ data: RentCost[]; }> {
    let retData = {
      data: [
        {
          id: 1234568,
          programId: 123456,
          programDetailId: 123456,
          rentId: 123456,
          costType: "string",
          unitPrice: 1000,
          count: 1,
          paid: 500,
          unpaid: 500,
          amount: 1000,
          rentStatus: "正常",
          status: "正常",
          remarkId: 123123,
          startDate: new Date('2021-10-12'),
          endDate: new Date('2022-7-1'),
        },
        {
          id: 1234569,
          programId: 123456,
          programDetailId: 123456,
          rentId: 123456,
          costType: "string",
          unitPrice: 1000,
          count: 1,
          paid: 500,
          unpaid: 500,
          amount: 1000,
          rentStatus: "正常",
          status: "正常",
          remarkId: 123412,
          startDate: new Date('2021-10-12'),
          endDate: new Date('2022-7-1'),
        }
      ],
    }
    let ret: RentCost[] = [];
    await request("/rent-cost/query_list", {
      method: "POST",
      data: {
        "id": options?.programId,
      }
    }).then(response => {
      ret = response.data;
    })
    return Promise.resolve({ data: ret });
  }
  async deleteOne(id: number): Promise<boolean> {
    console.log("need delete id is", id);
    await request("/rent-cost/delete_one", {
      method: "DELETE",
      data: {
        id
      }
    }).then(response => {
      // ret = response.data;
    })
    return Promise.resolve(true);
  }
  async updateOne(entity: RentCost): Promise<boolean> {
    console.log("need update id is", entity);
    await request("/rent-cost/update_one", {
      method: "PUT",
      data: {
        ...entity
      }
    }).then(response => {
      // ret = response.data;
    })
    return Promise.resolve(true);
  }
  async save(entity: RentCost): Promise<boolean> {
    console.log("保存成功");
    await request("/rent-cost/save_one", {
      method: "POST",
      data: {
        ...entity
      }
    }).then(response => {
      // ret = response.data;
    })
    return Promise.resolve(true);
  }
}
export const RentCostService = new RentCostServiceImpl();